#include <stdio.h>

int main(void) {
	int n, m, val, i;
	int arr[100];
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	for (int j = 0; j < m; j++) {
		scanf("%d", &arr[i + j]);
	}
	for (int i = 0; i < m + n - 1; i++) {
		for (int j = i + 1; j < m + n; j++) {
			if (arr[j] < arr[i])
				arr[j] = arr[j] ^ arr[i], arr[i] = arr[j] ^ arr[i], arr[j] = arr[j] ^ arr[i];
		}
	}
	for (int i = 0; i < m + n; i++) {
		printf("%d ", arr[i]);
	}
}